package org.example.groupwarehouse.service.login;

import org.example.groupwarehouse.entity.Users;
import org.example.groupwarehouse.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

/**
 * 密码登录策略实现类
 */
@Service
@Qualifier("passwordStrategy")
public class PasswordStrategy implements LoginStrategy {
    @Autowired
    private UserService userService;

    /**
     * 密码登录方法
     * @param params 登录参数，第一个是账号，第二个是密码
     */
    @Override
    public Users login(Object... params) {
        if (params.length < 2) {
            return null;
        }
        
        String account = (String) params[0];
        String password = (String) params[1];
        
        // 调用用户服务的登录方法进行验证
        return userService.login(account, password);
    }

    /**
     * 获取登录类型
     */
    @Override
    public String getLoginType() {
        return "password";
    }
} 